using System;
using System.Collections.Generic;
using System.Text;
using DTO.PO;

namespace DAO.PO
{
    public class OrderDAO
    {
        // insert don hang` moi vao` database (man` hinh` 1)
        public void InsertPurchaseOrder(Order order)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "insert into PO_Order(PONumber, Date, Status, SiteID, VendorID) values (" + order.POnumber + "," + "'"
                + order.Date.ToString("d") + "'" + "," + "'" + order.Status + "'" + "," + order.SiteId + "," + order.VendorId + ")";
            
            provider.ExcuteNonQuery(command);
            provider.Close();
        }

        // Update status cua don hang (man` hinh` 2)
        public void UpdateStatus(int poNumber, char status)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "update PO_Order set Status = " + status + "where PONumber = " + poNumber;

            provider.ExcuteNonQuery(command);
            provider.Close();
        }

        public void Delete(int poNumber)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "delete PO_Order where poNumber = " + poNumber;

            provider.ExcuteNonQuery(command);
            provider.Close();
        }
    }
}
